/*******************************************************************
 *   > File Name: buzzer.c
 *   > Author: fly
 *   > Mail: 1358326274@qq.com
 *   > Create Time: 2020年07月28日 星期二 22时09分35秒
 ******************************************************************/
#include "buzzer.h"

/* PWMOUT2(GPD0_2):高电平，响，低电平，灭；
*/

void buzzer_init(void)
{
    rGPD0CON &= ~(0x1<<8);
    rGPD0CON |= 0x1<<8;

    rGPD0DAT &= ~(0x1<<2);
}


//0:Off,1:On
void buzzer_set(unsigned int value)
{
    if(value == 1)
    {
        rGPD0DAT |= 0x1<<2;
    }
    else
    {
        rGPD0DAT &= ~(0x1<<2);
    }
}

void buzzer_test(void)
{
    buzzer_init();

    while(1)
    {
        buzzer_set(1); 
        delay(900000);
        buzzer_set(0); 
        delay(900000);
    }
}

void delay(unsigned long count)
{
    volatile unsigned long i = count;
            while(i--)
                        ;
}

